<template>
	<view style=" text-align: center;border: 1px solid gray;border: 1px solid gray;
    box-shadow: 0 15px 30px  rgba(0, 0, 0, .2);">
		<view class="image-content" >
			<image style="width:320px;height:520px;"  :src="pics"></image>
		</view>
		<view class="" style="display:flex;">
			<view @click="saveImg" style="justify-content:flex-start;width: 50%;"><button type="default">保存海报</button></view>
			<view class="" style="justify-content:flex-end;width: 50%;"><button @click="get_haibao()">生成海报</button></view>
		</view>
		
	</view>
	
	
</template>

<script>
	export default {
		data() {
			return {
				pics:'',
			}
		},
		onLoad(options) {
		   this.id=options.id;

		   this.get_user();
		},
		methods: {
			async get_haibao(){
				
				const res = await this.$myRuquest({
					url: 'index/dsnv.activities/get_haibao?id='+this.id
				})
				
				if(res.data.code==200) {
					this.pics=res.data.pic;
					
					console.log(res.data.pic);
					
					// setTimeout(() => {
					
					// 		this.$router.go(0)
							
					// 	}, 400)
				};

				
			},
			async get_user(){
				
				const res = await this.$myRuquest({
					url: 'index/dsnv.activities/get_user?id='+this.id +"&type="+ "hn"
				})
				this.pics=res.data.hn_pic;
			},
			
			  saveImg() {
					var oA = document.createElement("a");
					oA.download = ''; // 设置下载的文件名，默认是'下载'
					oA.href = this.pics;
					document.body.appendChild(oA);
					oA.click();
					oA.remove(); // 下载之后把创建的元素删除
				}
		
		}
	}
</script>

<style>

</style>
